package model.acs.qprs;
/**
 * AntApplication.java
 *
 * @author Created by Omnicore CodeGuide
 */

import java.util.*;
import java.io.*;

import control.Config;

import model.acs.*;

public class QPRSTest
{
	/*
    private static final int nNodes = 50;
    private static final int nAnts = 10;
    private static final int nIterations = 2002;
	 */
	
	@SuppressWarnings("unchecked")
	public static void main(String[] args)
	{
		Properties C;

		// Print application prompt to console.
		System.out.println("AntColonySystem for QPRS");        

		int nAnts = 100;
		int nNodes = -1;
		int nIterations = 50;
		int nRepetitions = 1;        

		// generate the graph
		try
		{     
			// Rotina de leitura do resultado do QuadTree
			
			ObjectInputStream ins = new ObjectInputStream(new FileInputStream(Config.workDir+"random_graph.bin"));
			double d[][] = (double[][])ins.readObject();
			ins.close();
			
			nNodes = d.length;	
	        
			AntGraph graph = new AntGraph(nNodes, d);			

			int nNodesInZArray[] = new int[2];
			nNodesInZArray[0] = 45;
			nNodesInZArray[1] = 44;
			
			for(int i = 0; i < nRepetitions; i++)
			{
				AntColony4QPRS antColony = new AntColony4QPRS(graph, nNodesInZArray, nAnts, nIterations);
				antColony.start();
				if(antColony.getBestPath()!=null){
					System.out.println(i + "," + antColony.getBestPathValue() + "," + antColony.getLastBestPathIteration() + "," + antColony.getBestPath().length);
					System.out.print("{");
					for(int k = 0; k < antColony.getBestPath().length; k++)
						System.out.print(antColony.getBestPath()[k] + " ");
					System.out.println("}");
				}
				else System.out.println("There's no path from "+nNodesInZArray[0]+" to "+nNodesInZArray[1]);
				graph.resetTau();
			}
		}
		catch(Exception ex)
		{
			ex.printStackTrace();
		}
	}
}

